﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AD_List.aspx.cs" validateRequest="false"  Inherits="ncp.Web.cms.AD_List" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>广告管理</title>
    <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../../themes/icon.css" />
    <link href="../../css/base.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="../../js/jquery-1.7.1.min.js"></script>
	<script type="text/javascript" src="../../js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../../js/common.js"></script>
	<script src="/Plugin/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
	<link href="/Plugin/uploadify/uploadify.css" rel="stylesheet" type="text/css" />
	<script src="/Plugin/uploadify/jquery.uploadify-3.1.min.js" type="text/javascript"></script>
</head>
<body style="margin:0; padding:0px;">
<form id="form1" runat="server">
    <div id="rightlayout" class="easyui-layout"  style="width:100%; height:498px;">
	    <div id="west" region="west" split="true" title="广告分类" style="width:220px;padding:1px;overflow:auto;">
	        <div class="toolbar" style="background-color:#efefef">
	            <a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-add" onclick="onAddClass();">增加</a>
		        <%--<a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-remove" onclick="onDeleteClass();">删除</a>--%>
		        <a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-edit" onclick="onEditClass();">编辑</a>
	        </div>
            <div id="divleft"></div>
	    </div>
	    <div id="east" region="center" title="广告管理">
	        <div class="toolbar" style="background-color:#efefef">
		        <a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-add" onclick="onAddAds();">增加</a>
		        <a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-remove" onclick="onDeleteNews();">删除</a>
		        <a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-edit" onclick="onEditNews();">编辑</a>
	        </div>
            <div id="divright">    
            </div>
	    </div>
	    <div id="divNewsInfoBox">
	        <div class="form mod-content">
            <table>
                <tr>
                    <td class="mod-label"> <label for="newsTitle">广告位名称:</label></td>
                    <td>
                    <input type="text" class="bh-input-long" style="width: 300px" maxlength="100" id="newsTitle"/>
                    <input type="hidden" id="hdAdId" value=""/>
                    <span class="msg"></span>
                    </td>
                </tr>
                <tr>
                    <td class="mod-label"> <label for="sort">广告排序:</label></td>
                    <td>
                    <input type="text" class="bh-input-small" maxlength="10" id="sort"/>
                    <span class="msg"></span>
                    </td>
                </tr>
                <tr>
                    <td class="mod-label"> <label for="newsTitle">广告分类:</label></td>
                    <td>
                    <select id="clsid">
                    </select>
                    <span class="msg"></span>
                    </td>
                </tr>
                <tr>
                    <td class="mod-label"> <label for="newsTitle">广告位描述:</label></td>
                    <td>
                    <textarea id="adInfos" rows="3" cols="50"></textarea>
                    <span class="msg"></span>
                    </td>
                </tr>
                <tr>
                    <td class="mod-label"> <label for="newsTitle">投放时间:</label></td>
                    <td>
                    从&nbsp;<input type="text" class="bh-input-def" id="startDate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>&nbsp;到&nbsp;<input type="text" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="bh-input-def" id="endDate"/>
                    <span class="msg"></span>
                    </td>
                </tr>
                <tr>
                    <td class="mod-label" style="vertical-align:top;"> <label for="proName">广告内容:</label></td>
                    <td style="height: 230px; vertical-align: top;">
                        <div class="typetab">
                            <ul id="changeTab">
                              <li id="t_code" class="act">代码</li>
                              <li id="t_txt" class="">文字</li>
                              <li id="t_img" class="">图片</li>
                              <li id="t_flash">Flash</li>
                            </ul>
                            <div style="clear:both"></div>
                          </div>
                          <div id="advert">
                              <table width="80%" cellpadding="3" cellspacing="1" class="i_table">
                                <tbody><tr class="b">
                                  <td width="200"><b>广告代码:</b><br>
                                    请填写广告代码，支持html代码</td>
                                  <td><textarea id="htmlCode" rows="5" cols="50"></textarea></td>
                                </tr>
                                </tbody>
                              </table>
                              <table width="80%" cellpadding="3" style="display: none" cellspacing="1" class="i_table">
                                <tbody><tr>
                                  <td class="b" width="200"><b>文字内容*</b></td>
                                  <td class="b"><input type="text" size="70" id="wordsValue" value="" class="iptxt"></td>
                                </tr>
                                <tr>
                                  <td class="b"><b>文字链接*</b></td>
                                  <td class="b"><input type="text" size="70" id="wordsAddr" value="" class="iptxt"></td>
                                </tr>
                                <tr>
                                  <td class="b"><b>文字颜色</b>(例如:red,#EF8684)</td>
                                  <td class="b"><input type="text" size="10" id="wordsColor" class="iptxt"></td>
                                </tr>
                                <tr>
                                  <td class="b"><b>文字大小</b>(例如:4px,12px)</td>
                                  <td class="b"><input type="text" size="10" id="wordsFontSize" class="iptxt"></td>
                                </tr>
                              </tbody>
                              </table>
                              <table width="80%" style="display: none;" cellpadding="3" cellspacing="1" class="i_table">
                                <tbody>
                                    <tr>
                                  <td class="b" width="200"><b>图片地址*</b></td>
                                  <td class="b">
                                      <input type="text" size="50" id="imgAddr" value="" class="iptxt">
                                      <div id="uploadifyImg" >
                                      </div>
                                  </td>
                                </tr>
                                <tr>
                                  <td class="b"><b>图片链接*</b></td>
                                  <td class="b">
                                      <input type="text" size="70" id="imgLink" value="" class="iptxt">
                                       
                                  </td>
                                </tr>
                                <tr>
                                  <td class="b"><b>图片宽度</b></td>
                                  <td class="b"><input type="text" size="10" id="imgWidth" value="" class="iptxt">(如：200px)</td>
                                </tr>
                                <tr>
                                  <td class="b"><b>图片高度</b></td>
                                  <td class="b"><input type="text" size="10" id="imgHeight" value="" class="iptxt">(如：200px)</td>
                                </tr>
                                <tr>
                                  <td class="b"><b>图片描述</b></td>
                                  <td class="b"><input type="text" size="40" id="imgTitle" value="" class="iptxt"></td>
                                </tr>
                              </tbody>
                              </table>
                              <table width="80%" style="display: none" cellpadding="3" cellspacing="1" class="i_table">
                                <tbody><tr>
                                  <td class="b" width="200"><b>flash链接</b></td>
                                  <td class="b">
                                      <input type="text" size="70" id="flashAddr" value="" class="iptxt">
                                      <div id="uploadifyFlash" >
                                      </div>
                                  </td>
                                </tr>
                                <tr>
                                  <td class="b"><b>flash宽度</b></td>
                                  <td class="b"><input type="text" size="10" id="flashWidth" value="" class="iptxt">(请填写数字)</td>
                                </tr>
                                <tr>
                                  <td class="b"><b>flash高度</b></td>
                                  <td class="b"><input type="text" size="10" id="flashHeight" value="" class="iptxt">(请填写数字)</td>
                                </tr>
                              </tbody></table>
                        </div>
                    </td>
                </tr>
                <tr>
            <td colspan="2" style="text-align: center;border-bottom: none;">
                <a href="javascript:void(0)" class="easyui-linkbutton" onclick="onSaveNews()">确定</a>&nbsp;&nbsp;
	            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="onCloseNewsWindow()">关闭</a>
            </td>
        </tr>
            </table>
        </div>
	    </div>
	    <div id="adClass">
	        <div class="mod-content">
	            <table>
	                <tr>
	                    <td><label for="newsTitle">分类名称:</label></td>
	                    <td><input type="text" id="textAdClass"/><input type="hidden" id="adClassId" value=""/></td>
	                    
	                </tr>
	                <tr>
	                    <td><label for="newsTitle">默认宽度:</label></td>
	                    <td><input type="text" id="textDefWidth"/></td>
	                </tr>
	                <tr>
	                    <td><label for="newsTitle">默认高度:</label></td>
	                    <td><input type="text" id="textDefHeight"/></td>
	                </tr>
	                <tr>
                        <td colspan="2" style="text-align: center;border-bottom: none;">
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="onSaveAdClass()">确定</a>&nbsp;&nbsp;
	                        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="onCloseClassWindow()">关闭</a>
                        </td>
                    </tr>
	            </table>
	        </div>
	    </div>
	</div>
	</form>
</body>
</html>
<script type="text/javascript">
    $(function() { //初始化
        LoadAdClass();
        initTree();
        initDialog();
        tabs();
        $("#uploadifyImg").uploadify({
            'swf': '/Plugin/uploadify/uploadify.swf',
            'auto': true,
            'fileTypeExts': '*.gif; *.jpg; *.png',
            'uploader': '/handler/AdsHandler.ashx',
            'multi': false,
            'formData': { 'folder': '/uploadFiles/ads/pic' },
            'buttonText': '本地上传',
            "fileSizeLimit":imgSizeLimit,
            'onUploadSuccess': function(file, data, response) {
                if (response) {
                    if (data != '0') {
                        $("#imgAddr").val(data);
                    } else {
                        alert("图片上传失败！");
                    }
                }
            }
        });
        $("#uploadifyFlash").uploadify({
            'swf': '/Plugin/uploadify/uploadify.swf',
            'auto': true,
            'fileTypeExts': '*.swf',
            'uploader': '/handler/AdsHandler.ashx',
            'multi': false,
            'formData': { 'folder': '/uploadFiles/ads/flash' },
            'buttonText': '本地上传',
            "fileSizeLimit": swfSizeLimit,
            'onUploadSuccess': function(file, d, response) {
                if (response) {
                    if (d != '0') {
                        $("#flashAddr").val(d);
                    } else {
                        alert("Flash上传失败！");
                    }
                }
            }
        });
    });

    //初始化tree
    function initTree() {
        $('#tt1').tree({
            onClick: function(node) {
                onSearch();
            }
        });
    }
    //初始化对话框
    function initDialog() {
        $('#divNewsInfoBox').dialog({
            title: '广告位',
            modal: true,
            width: $(window).width(),
            height: $(window).height(),
            left: 0,
            top: 0,
            padding: 10,
            closed: true,
            draggable: true,
            closable: true
        });
        $('#adClass').dialog({
            title: '分类名称',
            modal: true,
            width: 300,
            height: 180,
            left: 100,
            top: 200,
            padding: 10,
            closed: true,
            draggable: true,
            closable: true
        });
    }
    function tabs() {
        $("#changeTab li").click(function() {
            if (!$(this).hasClass("act")) {
                $(this).addClass("act");
                $(this).siblings().removeClass("act");
                var text = $(this).text();
                $("#advert table").hide();
                if (text == "代码") {
                    $("#advert table:eq(0)").show();
                }
                if (text == "文字") {
                    $("#advert table:eq(1)").show();
                }
                if (text == "图片") {
                    $("#advert table:eq(2)").show();
                }
                if (text == "Flash") {
                    $("#advert table:eq(3)").show();
                }
                //$("#advert input,#advert textarea").val("");
            }
        });
    }
    function emptyData() {
        $("#divNewsInfoBox input").val("");
        $("#divNewsInfoBox textarea").val("");
    }
    
    //关闭窗口
    function onCloseNewsWindow() {
        $('#divNewsInfoBox').window('close');
    }
    function onCloseClassWindow() {
        $('#adClass').window('close');
    }
    //添加分类
    function onAddClass() {
        $("#adClass input").val("");
        $('#adClass').dialog('setTitle', '添加分类');
        $('#adClass').dialog("open");
    }
    //修改
    function onEditClass() {
        $("#adClass input").val("");
        var node = $('#tt1').tree('getSelected');
        if (node == null) {
            alert("请选择要修改的分类");
            return;
        }
        if (node.id == 1) {
            alert("该分类不允许修改!");
            return;
        }
        var sp = node.id.split('_');
        $("#adClassId").val(sp[0]);
        $("#textAdClass").val(node.text);
        $("#textDefWidth").val(sp[1]);
        $("#textDefHeight").val(sp[2]);
        $('#adClass').dialog('setTitle', '修改分类');
        $('#adClass').dialog("open");
    }
    //保存广告分类
    function onSaveAdClass() {
        var adClassId = $("#adClassId").val() == "" ? 0 : $("#adClassId").val();
        if (adClassId) {
        }
        var width = $("#textDefWidth").val() == "" ? 0 : $("#textDefWidth").val();
        var height = $("#textDefHeight").val() == "" ? 0 : $("#textDefHeight").val();
        var className = $("#textAdClass").val();
        if ($.trim(className) == "") {
            alert("广告分类名称不能为空");
        }
        var response = ncp.Web.cms.AD_List.UpdateAdClass(adClassId,className,width,height);
        if (response.value != null) {
            var jsonOBJ = eval(response.value)[0];
            if (jsonOBJ.isreload) {
                LoadAdClass();
                initTree();
                onCloseClassWindow();
            }
            alert(jsonOBJ.msg);
        }
    }
    //删除分类
    function onDeleteClass() {
        var node = $('#tt1').tree('getSelected');
        if (node == null) {
            alert("请先选择一条记录");
            return;
        }
        if (node.id == 1) {
            alert("不允许删除该分类！");
            return;
        }
        if (confirm("您确定要删除该分类吗？该分类下的广告将会被移动到默认分类下")) {
            var response = ncp.Web.cms.AD_List.DeleteClass(node.id);
            if (response.value != null) {
                var jsonOBJ = eval(response.value)[0];
                if (jsonOBJ.isreload) {
                    LoadAdClass();
                    initTree();
                    onCloseClassWindow();
                }
                alert(jsonOBJ.msg);
            }
        }
    }

    //装载类别视图
    function LoadAdClass() {
        var response = ncp.Web.cms.AD_List.ShowNewsClassTree();
        if (response.value != null) {
            var jsonOBJ = eval(response.value)[0];
            if (jsonOBJ.isreload) {
                $("#divleft").html(jsonOBJ.msg);
            } else
                alert(jsonOBJ.msg);
        }
    }

    //得到本节点和它的子节点
    function getChildren() {
        var node = $('#tt1').tree('getSelected');
        if (node == null) return "";

        var s = node.id;
        var children = $('#tt1').tree('getChildren', node.target);

        for (var i = 0; i < children.length; i++) {
            s += ',' + children[i].id;
        }
        return s;
    }

</script>

<%--广告列表--%>
<script type="text/javascript">
    var pageobj = new Object();

    $(function() {
        initPageObj();
        initDatagrid();
        LoadNewsInfo();
        initPager();

    });
    
    //初始化页码对象
    function initPageObj() {
        pageobj.currentpageindex = 1;
        pageobj.pagesize = 10;
        pageobj.sorting = "endtime";
        pageobj.sortdir = "asc";
        pageobj.currentwhere = GetstrWhere();
        pageobj.recordcount = GetRecordCount();
    }

    //初始化表格
    function initDatagrid() {
        $('#divright').datagrid({
            height: $(window).height() - 61,
            nowrap: true,
            striped: true,
            singleSelect: true,
            sortName: 'endtime',
            sortOrder: 'asc',
            remoteSort: false,
            idField: 'id',
            pagination: true,
            rownumbers: true,
            columns: [[
					{ field: 'id', title: '编号', width: 40 },
					{ field: 'classname', title: '分类', sortable: 'true', width: 80 },
					{ field: 'name', title: '广告名称', sortable: 'false', width: 150, align: 'center' },
                {field:'sort',title:'排序',sortable:'true',width:50,align:'center'},
					{ field: 'time', title: '开始时间', sortable: 'true', width: 130 },
					{ field: 'endtime', title: '结束时间', sortable: 'true', width: 130,
					    styler: function(val, row, index) {
					    var date = new Date();
					    var myyear = date.getYear();
					    var yy = (myyear > 200) ? myyear : 1900 + myyear;
					    var mm = (date.getMonth() + 1) < 10 ? "0" + (date.getMonth() + 1) : (date.getMonth() + 1);
					    var dd = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
					    var nowdate = yy + "-" + mm + "-" + dd + " " + date.toLocaleTimeString();
					    var d2 = nowdate.replace(/-/g, "/");
					    if (Date.parse(d2) > Date.parse(val.replace(/-/g, "/"))) {
					            return 'color:red;font-weight:bold;';
					        }
					    }
					},
                { field: 'infor', title: '广告位描述', sortable: 'true', width: 300 }
				]]
        });
    }
    

    function initPager() {
        var p = $('#divright').datagrid('getPager');
        $(p).pagination({
            total: pageobj.recordcount,
            pageSize: pageobj.pagesize,
            pageList: [10, 15, 20, 25, 30],
            showRefresh: true,
            showPageList: true,
            beforePageText: '第',
            afterPageText: '页 共 {pages} 页',
            displayMsg: '当前显示 {from} - {to} 条记录 共 {total} 条记录',
            onSelectPage: function(pageNumber, pageSize) {
                $(this).pagination('loading');
                onShowPageNo(pageNumber, pageSize);
                $(this).pagination('loaded');
            }
        });
    }

    //翻页
    function onShowPageNo(pageNumber, pageSize) {
        pageobj.pagesize = pageSize;
        pageobj.currentpageindex = pageNumber;
        LoadNewsInfo();
        initPager();
        return false;
    }

    //得到条件
    function GetstrWhere() {
        var myWhere = "1=1";
        var classid = getChildren();
        if (classid != "") myWhere += " and classid in (" + classid + ")";
        return myWhere;
    }

    //得到总记录数
    function GetRecordCount() {
        var response = ncp.Web.cms.AD_List.GetRecordCount(pageobj.currentwhere);
        if (response.value != null) {
            return response.value;
        }
        else
            return 0;
    }

    //查询
    function onSearch() {
        pageobj.currentpageindex = 1;
        pageobj.currentwhere = GetstrWhere();
        pageobj.recordcount = GetRecordCount();
        LoadNewsInfo();
        initPager();
        return false;
    }

    //装载商品信息视图
    function LoadNewsInfo() {
        var jsonStr = $.objectToJson(pageobj);
        var response = ncp.Web.cms.AD_List.BindTable(jsonStr);
        if (response.value != null) {
            var data = eval(response.value);
            $('#divright').datagrid('loadData', data);
        }
    }

    //获取所有分类列表
    function getAdClass() {
        var response = ncp.Web.cms.AD_List.GetAdClass();
        if (response.value != null) {
            var data = eval(response.value)[0];
            $('#clsid').html(data.msg);
        }
    }

    //增加新闻
    function onAddAds() {
        getAdClass();
        $("#hdAdId").val("");
        $('#divNewsInfoBox').dialog('setTitle', '添加广告');
        $('#divNewsInfoBox').dialog("open");
        emptyData();
        getDefSize();
        return false;
    }
    
    function getDefSize() {
        var sp = $("#clsid").find("option:selected").attr("defsize").split("_");
        var width = sp[0] == "" ? "" : sp[0] + "px";
        var height = sp[1] == "" ? "" : sp[1] + "px";
        $("#imgWidth").val(width);
        $("#imgHeight").val(height);
        $("#flashWidth").val(sp[0]);
        $("#flashHeight").val(sp[1]);
        $("#clsid").change(function() {
            sp = $("#clsid").find("option:selected").attr("defsize").split("_");
            width = sp[0] == "" ? "" : sp[0] + "px";
            height = sp[1] == "" ? "" : sp[1] + "px";
            $("#imgWidth").val(width);
            $("#imgHeight").val(height);
            $("#flashWidth").val(sp[0]);
            $("#flashHeight").val(sp[1]);
        });
    }

    //保存新闻
    function onSaveNews() {
        //执行上传
        var obj = new Object();
        obj.id = $("#hdAdId").val();
        obj.name = $("#newsTitle").val();
        obj.infor = $("#adInfos").val();
        obj.adid = $('#clsid').val();
        obj.time = $("#startDate").val();
        obj.endtime = $("#endDate").val();
        obj.sort = $("#sort").val() == "" ? 0 : $("#sort").val();
        if (isNaN(obj.sort)) {
            alert("排序只能为数字！");
            return;
        }
        if ($.trim(obj.name) == "") {
            alert("请填写广告名称！");
            return;
        }
        if ($.trim(obj.time) == "" || $.trim(obj.endtime) == "") {
            alert("请选择广告投放时间！");
            return;
        }
        var selectedTab = $("#changeTab li.act").text();
        switch (selectedTab) {
            case "代码":
                obj.type = 1;
                obj.html = $("#htmlCode").val();
                break;
            case "文字":
                obj.type = 2;
                obj.content = $("#wordsValue").val();
                obj.url = $("#wordsAddr").val();
                obj.color = $("#wordsColor").val();
                obj.fontsize = $("#wordsFontSize").val();
                break;
            case "图片":
                obj.type = 3;
                obj.picture = $("#imgAddr").val();
                obj.url = $("#imgLink").val();
                obj.width = $("#imgWidth").val();
                obj.height = $("#imgHeight").val();
                obj.content = $("#imgTitle").val();
                if (obj.width == "" || obj.width.indexOf("px") <= 0) {
                    alert("请输入图片宽度(注意加单位px)！");
                    return;
                }
                if (obj.height == "" || obj.height.indexOf("px") <= 0) {
                    alert("请输入图片高度(注意加单位px)！");
                    return;
                }
                break;
            case "Flash":
                obj.type = 4;
                obj.url = $("#flashAddr").val();
                obj.width = $("#flashWidth").val();
                obj.height = $("#flashHeight").val();
                if (obj.width == "" || obj.width.indexOf("px") <= 0) {
                    alert("请输入flash宽度(注意加单位px)！");
                    return;
                }
                if (obj.height == "" || obj.height.indexOf("px") <= 0) {
                    alert("请输入flash高度(注意加单位px)！");
                    return;
                }
                break;
        }
        if (selectedTab == "图片" || selectedTab == "Flash") {
            if (obj.width == "") {
                alert("请设置广告宽度");
                return;
            }
            if (obj.height == "") {
                alert("请设置广告高度");
                return;
            }
        }
        var response = ncp.Web.cms.AD_List.OnSave($.objectToJson(obj));
        if (response.value != "") {
            var jsonOBJ = eval(response.value)[0];
            alert(jsonOBJ.msg);
            if (jsonOBJ.isreload) {
                onSearch();
                onCloseNewsWindow();
                emptyData();
            }
        }
    }

    //编辑商品
    function onEditNews() {
        emptyData();
        getAdClass();
        var selected = $('#divright').datagrid('getSelected');
        if (selected) {
            $('#divNewsInfoBox').dialog('setTitle', '编辑新闻');
            $('#divNewsInfoBox').dialog("open");
            $("#hdAdId").val(selected.id);
            $("#sort").val(selected.sort);
            $("#newsTitle").val(selected.name);
            $("#adInfos").val(selected.infor);
            $('#clsid').val(selected.classid);
            $("#startDate").val(selected.time);
            $("#endDate").val(selected.endtime);
            $("#changeTab li").removeClass("act");
            $("#changeTab li").eq(selected.type - 1).addClass("act");
            $("#advert table").hide();
            $("#advert table").eq(selected.type - 1).show();
            switch (selected.type) {
                case 1:
                    $("#htmlCode").val(selected.html);
                    break;
                case 2:
                    $("#wordsValue").val(selected.content);
                    $("#wordsAddr").val(selected.url);
                    $("#wordsColor").val(selected.color);
                    $("#wordsFontSize").val(selected.fontsize);
                    break;
                case 3:
                    $("#imgAddr").val(selected.picture);
                    $("#imgLink").val(selected.url);
                    $("#imgWidth").val(selected.width);
                    $("#imgHeight").val(selected.height);
                    $("#imgTitle").val(selected.content);
                    break;
                case 4:
                    $("#flashAddr").val(selected.url);
                    $("#flashWidth").val(selected.width);
                    $("#flashHeight").val(selected.height);
                    break;
            }
        }
        else
            alert("请先选择一条记录！");
        return false;
    }

    //删除商品
    function onDeleteNews() {
        var selected = $('#divright').datagrid('getSelected');
        if (selected) {
            if (confirm("您确定要删除吗？")) {
                var response = ncp.Web.cms.AD_List.DeleteADInfo(selected.id);
                if (response.value != null) {
                    var jsonOBJ = eval(response.value)[0];
                    if (jsonOBJ.isreload) {
                        onSearch();
                    }
                    alert(jsonOBJ.msg);
                }
            }
        }
        else
            alert("请先选择一条记录！");
        return false;
    }
</script>